import request from '../../../../../public/js/common/api/api.js';

const CBSUrl = Utils.CurDomain.CBSUrl;
const SysPlfUrl = Utils.CurDomain.SysPlfUrl;
const MasterDataUrl = Utils.CurDomain.MasterDataUrl;
const SubDataUrl = Utils.CurDomain.SubDataUrl;
const AuthUrl = Utils.CurDomain.AuthUrl;

const _ajaxOptions = {
    contentType: 'application/json',
    dataType: 'text',
    async: true,
    dataFilter(data, type) {
        return data;
    }
};
export default class ReceivepigApi {

    /**
     * 查询接苗单Dt列表
     * @param data
     * @returns 
     */
    static postReceivePigBillList(data) {
        return request.post(`${CBSUrl}/receivepigbills/list`, data);
    }

    /**
     * 创建 接苗单
     * @param data
     * @returns 
     */
    static postReceivePigBill(data) {
        return request.post(`${CBSUrl}/receivepigbills`, data, true, _ajaxOptions);
    }

    /**
     * 更新 接苗单
     * @param data
     * @returns 
     */
    static putReceivePigBill(id, data) {
        return request.put(`${CBSUrl}/receivepigbills/${id}`, data, true, _ajaxOptions);
    }

    /**
     * 查询接苗单详情
     * @param data
     * @returns
     */
    static getReceivePigBill(id) {
        return request.get(`${CBSUrl}/receivepigbills/${id}`);
    }

    /**
     * 生成送苗单
     * @param data
     * @returns
     */
    static postReceivePigGenerate(data) {
        return request.post(`${CBSUrl}/receivepigbills/generate`, data, true, _ajaxOptions);
    }

    /**
     * 删除 接苗单
     * @param data
     * @returns 
     */
    static deleteReceivePigBill(id) {
        return request.delete(`${CBSUrl}/receivepigbills/${id}`);
    }

    /**
     * 提交 接苗单
     * @param ids
     * @returns 
     */
    static submitReceiveTables(ids) {
        return request.put(`${CBSUrl}/receivepigbills/submit/${ids.id}`, ids);
    }
    /**
     * 反提交 接苗单
     * @param ids
     * @returns 
     */
    static rollSubmitReceiveTables(ids) {
        return request.put(`${CBSUrl}/receivepigbills/resubmit/${ids.id}`, ids);
    }
    /**
     * 审核 接苗单
     * @param ids
     * @returns 
     */
    static auditReceiveTables(ids) {
        return request.put(`${CBSUrl}/receivepigbills/audit/${ids.id}`, ids);
    }
    /**
     * 反审核 接苗单
     * @param ids
     * @returns 
     */
    static rollReceiveTables(ids) {
        return request.put(`${CBSUrl}/receivepigbills/reaudit/${ids.id}`, ids);
    }

    /**
    *获取参数设置的值
    * @param {*} data
    * @returns 
    */
    static getPrmtSettings(id) {
        return request.get(`${SubDataUrl}/prmtsettings/${id}/value`);
    }

    /**
    * 获取财务组织
    * @param 
    * @returns 
    */
    static getOrgHrList(upoid, aotype) {
        return request.get(`${SysPlfUrl}/yyorgunits/by/q/fi`);
    }

    /**
    * 获取当前用户拥有的组织
    * @param 
    * @returns 
    */
    static getOrgsList() {
        return request.get(`${AuthUrl}/accounts/orgs`);
    }

    /**
    * 获取供应商详情
    * @param data
    * @returns 
    */
    static getSupplier(param) {
        return request.get(`${MasterDataUrl}/yysuppliers/by/q?SearchInfo=${param}`);
    }

    /**
    * 获取客户信息
    * @param data
    * @returns 
    */
    static getCustomerList() {
        return request.get(`${MasterDataUrl}/yycustomers/by/q`);
    }

    /**
    * 获取人员信息
    * @param data
    * @returns 
    */
    static getPersonList() {
        return request.get(`${MasterDataUrl}/yypersons/by/q`);
    }

    /**
    * 获取服务部信息
    * @param data
    * @returns 
    */
    static queryComDepList(upoid, aotype) {
        return request.get(`${SysPlfUrl}/yyorgunits/by/q?upoid=${upoid}&aotype=${aotype}`);
    }

    /**
    * 获取服务部信息
    * @param data
    * @returns 
    */
    static queryBaseOrgunitList(upoid, aotype, taginfo) {
        return request.get(`${SysPlfUrl}/yyorgunits/by/q?upoid=${upoid}&aotype=${aotype}&taginfo=${taginfo}`);
    }

    /**
    * 获取行政区划列表信息
    * @param {*} id 
    * @returns 
    */
    static getDistrictsType(type, id) {
        return request.get(`${SubDataUrl}/districts/q?l=${type}&pid=${id}`);
    }

    /**
    * 根据养户查询关联的养殖批次
    * @param {*} id 
    * @returns 
    */
    static getFosterBatch(id) {
        return request.get(`${CBSUrl}/fosterfarmers/batch/${id}`);
    }
}